import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CommonText extends StatelessWidget {
  final String txt;
  final Color txtColor;
  final FontWeight txtWeight;
  final double txtSize;
  final int maxLine;
  final TextOverflow overflow;

  const CommonText(
    this.txt, {
    Key key,
    this.txtColor = Colors.black,
    this.txtWeight = FontWeight.normal,
    this.txtSize = 12,
    this.maxLine,
    this.overflow,
  }) : super(key: key);

  CommonText.singleLine(
    this.txt, {
    Key key,
    this.txtColor = Colors.black,
    this.txtWeight = FontWeight.normal,
    this.txtSize = 12,
    this.maxLine = 1,
    this.overflow,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Text(
      txt ?? "",
      style: TextStyle(
        color: txtColor,
        fontWeight: txtWeight,
        fontSize: txtSize,
      ),
      overflow: overflow ?? (maxLine == 1 ? TextOverflow.ellipsis : DefaultTextStyle.of(context).overflow),
      maxLines: maxLine ?? DefaultTextStyle.of(context).maxLines,
    );
  }
}
